package Demo1;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 殇
 * Date: 2025-06-04
 * Time: 16:06
 */
public class Cat extends Animal{
    public Cat(String name){
        super(name);
        this.name=name;
    }
    @Override
    public void eat(){
        System.out.println(name+"正在吃猫粮");
    }

    public void catchMouse(){
        System.out.println(name+"正在抓老鼠...");
    }
    void makeAnimalSound(Animal animal) {
        if (animal instanceof Cat) {
            ((Cat) animal).catchMouse();
        } else if (animal instanceof Dog) {
            ((Dog) animal).bark();
        }
    }
    public static void main(String[] args) {
        Cat cat =new Cat("小白");

        Animal animal=cat;

        cat=(Cat)animal;

    }
}
